<template>
	<!--票夹详情-->
	<view class="content">
		<view class="ad-billing">
			<!--表单开始-->
			<form>

				<view class="uni-details-list">
					<view class="title">名称:</view>
					<view class="uni-input-01">{{riseListPro.invoiceName}}</view>
				</view>

				<view class="uni-details-list">
					<view class="title">税号:</view>
					<view class="uni-input-01">{{riseListPro.taxNo}}
					</view>
				</view>

				<view class="uni-details-list">
					<view class="title">企业地址:</view>
					<view class="uni-input-02"> {{riseListPro.address}}
					</view>
				</view>

				<view class="uni-details-list">
					<view class="title">企业电话:</view>
					<view class="uni-input-02">{{riseListPro.phone}}
					</view>
				</view>

				<view class="uni-details-list">
					<view class="title">开户银行:</view>
					<view class="uni-input-02">{{riseListPro.bankAccNo}}
					</view>
				</view>

				<view class="uni-details-list">
					<view class="title">开户账号:</view>
					<view class="uni-input-02">{{riseListPro.bankNm}}
					</view>
				</view>

				<view class="uni-details-list">
					<view class="title">金额:</view>
					<view class="uni-input-01">{{riseListPro.txnAmt}}
					</view>
				</view>

				<view class="uni-details-list">
					<view class="title">内容:</view>
					<view class="uni-input-01">{{riseListPro.content}}</view>
				</view>

				<view class="uni-details-list">
					<view class="title">备注:</view>
					<view class="uni-input-01">{{riseListPro.memo}}</view>
				</view>
				
				<view class="uni-details-list">
					<view class="title">商家:</view>
					<view class="uni-input-01">{{riseListPro.merchant.merchantName}}</view>
				</view>

				<view class="uni-details-list">
					<view class="title">邮箱:</view>
					<view class="uni-input-01">{{riseListPro.email}}
					</view>
				</view>


				<view class="uni-details-list">
					<view class="title">状态：</view>
					<view v-if="riseListPro.state == '1'">客户新增</view>
					<view v-else-if="riseListPro.state == '2'">商家已处理</view>
					<view v-else-if="riseListPro.state == '3'">后台已处理</view>
					<view v-else-if="riseListPro.state == '4'">已退回</view>
				</view>

				<!--提交按钮-->
				<view class="ad-button"><button form-type="submit" @tap="keyword" class="button"
						v-if="riseListPro.state == '4'">提交</button></view>

			</form>
			<!--表单结束-->
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				riseListPro: {
					invoiceName: '',
					taxNo: '',
					address: '',
					phone: '',
					bankNm: '',
					bankAccNo: '',
					txnAmt: '',
					state: '',
					email: '',
					content:'',
					memo:'',
					merchant: {
						id: '',
						merchantName: ''
					}
				}
			};
		},
		onLoad(options) {
			console.log(options.id);
			this.detail(options.id);
		},
		methods: {
			//订单详情
			detail(id) {
				var me = this;
				console.log(id);
				uni.request({
					url: me.$ServerUrl + '/invoice/api/invoice/getInvoiceById', //通过ID获取发票详情
					data: {
						id: id
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded' // 默认值JSON格式
					},
					method: 'GET',
					success(res) {
						console.log(res.data);
						me.riseListPro = res.data;
						console.log('riseListPro' + JSON.stringify(me.riseListPro.merchant.id));
					}
				});
			},
			keyword(e) {
				var userinfo = uni.getStorageSync('user');
				//打印数值
				console.log('user' + JSON.stringify(userinfo));
				console.log(e);
				var me = this;
				console.log('-------111111111-----');
				console.log(me.riseListPro);
				// var Rise = this;
				uni.request({
					url: me.$ServerUrl + '/invoice/api/invoice/invoicing', //修改发票
					header: {
						'content-type': 'application/json' // 默认值
					},
					data: {
						id: me.riseListPro.id,
						merchant: {
							id: me.riseListPro.merchant.id //商家ID
						},
						customer: {
							id: userinfo.id //用户id
						},
						invoiceName: me.riseListPro.invoiceName,
						taxNo: me.riseListPro.taxNo,
						address: me.riseListPro.address,
						phone: me.riseListPro.phone,
						bankNm: me.riseListPro.bankNm,
						bankAccNo: me.riseListPro.bankAccNo,
						email: me.riseListPro.email,
						txnAmt: me.riseListPro.txnAmt,
						content:me.riseListPro.content,
						memo:me.riseListPro.memo,
						state: 4
					},
					method: 'POST',
					success(res) {
						console.log(res);
						uni.showModal({
							content: '提交成功',
							showCancel: false,
							success() {
								uni.switchTab({
									url: '../../home/index'
								});
							}
						});
					}
				});
			}
		}
	};
</script>

<style>
	page {
		width: 100%;
		height: 100%;
		background-color: #e1e5eb;
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.ad-billing {
		width: 100%;
		height: 100%;
		padding: 10px;
	}

	.uni-details-list {
		border: 1px solid #ffffff;
		display: flex;
		background-color: #ffffff;
		align-items: center;
		padding: 10px;
		margin-bottom: 5px;
		border-radius: 10px;
		margin-left: 10px;
		margin-right: 10px;
	}

	.title {
		font-size: 14px;
		width: 65px;
	}

	.uni-input-01 {
		font-size: 14px;
		margin-left: 10px;
		width: 80%;
		overflow: auto;
	}

	.uni-input-01 input {
		width: 90%;
	}

	.uni-input-02 input {
		width: 90%;
	}

	.uni-input-02 {
		font-size: 14px;
		margin-left: 5px;
		width: 80%;
		overflow: auto;
	}
</style>
